{extend name='admin@public/content'}

{block name="button"}

{/block}
{block name="style"}
<style>
    .teuh{font-size:20px}

</style>
{/block}
{block name='content'}
<form onsubmit="return false;" data-auto="true" action="{:request()->url()}" method="post">
    <!--{if empty($list)}-->
    <p class="help-block text-center well">一 级 团 队 没 有 记 录 哦！</p>
    <!--{else}-->
    <label class="col-sm-5 control-label teuh">一级团队(<?php echo count($list)?>)</label>
    <table class="layui-table" lay-skin="line">
        <thead>
        <tr>
            <th class="text-left nowrap">微信昵称</th>
            <th class="text-left nowrap">用户名</th>
            <th class="text-left nowrap">手机号</th>
            <th class="text-left nowrap">会员等级</th>
            <th class="text-left nowrap">注册时间</th>
            <th class="text-left nowrap">状态</th>
            <th class="text-left nowrap">上级用户</th>
            <th class="text-left nowrap">团队人数</th>
            <th class="text-left nowrap">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='text-left nowrap'>{$vo.nickname|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.username|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.mobile|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.name|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.add_time|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.is_delete|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.pater|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.teamcount|default='暂无'}</td>
            <td class='text-center nowrap'>
                <span class="text-explode">|</span>
                <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("$classuri/edit")}?id={$vo.id}'>详情</a>
                <span class="text-explode">|</span>
                <a class="layui-btn layui-btn-xs layui-btn-normal" data-open='{:url("$classuri/capiDetails")}?id={$vo.id}'>查看用户钱包</a>
            </td>
        </tr>
        {/foreach}

        </tbody>
    </table>
    <!--{/if}-->
    <!--{if empty($twoTeam)}-->
    <p class="help-block text-center well">二 级 团 队 没 有 记 录 哦！</p>
    <!--{else}-->
    <label class="col-sm-5 control-label teuh">二级团队(<?php echo  count($twoTeam)?>)</label>
    <table class="layui-table" lay-skin="line">
        <thead>
        <tr>
            <th class="text-left nowrap">微信昵称</th>
            <th class="text-left nowrap">用户名</th>
            <th class="text-left nowrap">手机号</th>
            <th class="text-left nowrap">会员等级</th>
            <th class="text-left nowrap">注册时间</th>
            <th class="text-left nowrap">状态</th>
            <th class="text-left nowrap">上级用户</th>
            <th class="text-left nowrap">团队人数</th>
            <th class="text-left nowrap">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $twoTeam as $key=>$vo}
        <tr>
            <td class='text-left nowrap'>{$vo.nickname|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.username|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.mobile|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.name|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.add_time|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.is_delete|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.pater|default='暂无'}</td>
            <td class='text-left nowrap'>{$vo.teamcount|default='暂无'}</td>
            <td class='text-center nowrap'>
                <span class="text-explode">|</span>
                <a class="layui-btn layui-btn-xs" data-open='{:url("$classuri/edit")}?id={$vo.id}'>详情</a>
                <span class="text-explode">|</span>
                <a class="layui-btn layui-btn-xs" data-open='{:url("$classuri/capiDetails")}?id={$vo.id}'>查看用户钱包</a>
            </td>
        </tr>
        {/foreach}

        </tbody>
    </table>
    {if isset($page)}<p>{$page|raw}</p>{/if}
    <!--{/if}-->
</form>

{/block}

{block name="script"}
<script>

    $(function () {
        /**
         * 默认类型事件
         * @type String
         */
        $('body').off('change', 'select[name=type]').on('change', 'select[name=type]', function () {
            var value = $(this).val(), $form = $(this).parents('form');
            var $current = $form.find('[data-keys-type="' + value + '"]').removeClass('hide');
            $form.find('[data-keys-type]').not($current).addClass('hide');
            switch (value) {
                case 'news':
                    return $('[name="news_id"]').trigger('change');
                case 'text':
                    return $('[name="content"]').trigger('change');
                case 'image':
                    return $('[name="image_url"]').trigger('change');
                case 'video':
                    return $('[name="video_url"]').trigger('change');
                case 'music':
                    return $('[name="music_url"]').trigger('change');
                case 'voice':
                    return $('[name="voice_url"]').trigger('change');
            }
        });

        function showReview(params) {
            params = params || {};
            $('#phone-preview').attr('src', '{"@wechat/review"|app_url}&' + $.param(params));
        }

        // 图文显示预览
        $('body').off('change', '[name="news_id"]').on('change', '[name="news_id"]', function () {
            showReview({type: 'news', content: this.value});
        });
        // 文字显示预览
        $('body').off('change', '[name="content"]').on('change', '[name="content"]', function () {
            showReview({type: 'text', content: this.value});
        });
        // 图片显示预览
        $('body').off('change', '[name="image_url"]').on('change', '[name="image_url"]', function () {
            showReview({type: 'image', content: this.value});
        });
        // 音乐显示预览
        var musicSelector = '[name="music_url"],[name="music_title"],[name="music_desc"],[name="music_image"]';
        $('body').off('change', musicSelector).on('change', musicSelector, function () {
            var params = {type: 'music'}, $parent = $(this).parents('form');
            params.title = $parent.find('[name="music_title"]').val();
            params.url = $parent.find('[name="music_url"]').val();
            params.image = $parent.find('[name="music_image"]').val();
            params.desc = $parent.find('[name="music_desc"]').val();
            showReview(params);
        });
        // 视频显示预览
        var videoSelector = '[name="video_title"],[name="video_url"],[name="video_desc"]';
        $('body').off('change', videoSelector).on('change', videoSelector, function () {
            var params = {type: 'video'}, $parent = $(this).parents('form');
            params.title = $parent.find('[name="video_title"]').val();
            params.url = $parent.find('[name="video_url"]').val();
            params.desc = $parent.find('[name="video_desc"]').val();
            showReview(params);
        });

        // 默认事件触发
        $('select[name=type]').map(function () {
            $(this).trigger('change');
        });

        /*! 删除关键字 */
        $('[data-delete]').on('click', function () {
            var id = this.getAttribute('data-delete');
            var url = this.getAttribute('data-action');
            var dialogIndex = $.msg.confirm('确定要删除这条记录吗？', function () {
                $.form.load(url, {id: id}, 'post', function (ret) {
                    if (ret.code === "SUCCESS") {
                        window.location.reload();
                    }
                    $.msg.close(dialogIndex);
                });
            })
        });
    });
</script>
{/block}